package com.zh.note.huawei.onehundred.找出通过车辆最多颜色;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: zhanghuan
 * @date: 2023/8/6 20:15
 * @description: create it
 */
public class Main {
    public static void main(String[] args) {
        // Scanner sc = new Scanner(System.in);
        // String input = sc.nextLine();
        // int count = sc.nextInt();
        int k = 3;//窗口大小
        String input = "0 1 2 1 1 1";
        String[] arr = input.split(" ");
        int max = 0;
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            if (i >= k) {
                String key = arr[i - k];
                map.put(key, map.get(key) - 1);
            }
            int count = map.getOrDefault(arr[i], 0);
            map.put(arr[i], count + 1);
            if (count + 1 > max) {
                max = count + 1;
            }
        }
        System.out.println(max);

    }
}
